<?php
declare(strict_types=1);
namespace app\api\controller\admin;

use app\common\controller\Api;
use app\common\model\delivery\Channel;
use app\common\model\delivery\Seller;

class Base extends Api {

    protected $channel;

    protected $seller;

    protected function _initialize()
    {
        parent::_initialize();
        $channel= Channel::where("FIND_IN_SET({$this->auth->id},user_id)")->find();
        if($channel){
            $this->channel=$channel;
            return;
        }
        $seller= Seller::withJoin(['channel'],'right')->where(['seller.user_id'=>$this->auth->id,'seller.status'=>'normal'])->find();
        if($seller){
            $this->seller=$seller;
            $this->channel=$seller->channel;
            return;
        }
        $this->error('你没有操作权限');
    }
}